﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace demoStack
{
    class Program
    {
        public struct TrangThai
        {
            public int soDia;
            public int num;
            public char X;
            public char Y;
            public char Z;
            public TrangThai(int m,int n,char x,char y,char z)
            {
                soDia = m;
                num = n;
                X = x;
                Y = y;
                Z = z;
            }
        }
        static void Main(string[] args)
        {
            System.Console.WriteLine("Thap Ha Noi\n");
            int n=3;
            char x='A';
            char y='B';
            char z='C';
            Stack<TrangThai> st = new Stack<TrangThai>();
            TrangThai tt = new TrangThai(n, n, x, y, z);
            st.Push(tt);
            while (st.Count != 0)
            {
               TrangThai tt0= st.Pop();
                if (tt0.num == 1)
                    Chuyen(tt0.soDia, tt0.X, tt0.Z);
                else
                {
                    TrangThai tt1 = new TrangThai(tt0.soDia - 1, tt0.soDia - 1, tt0.Y, tt0.X, tt0.Z);
                    st.Push(tt1);
                    TrangThai tt2=new TrangThai(tt0.soDia,1,tt0.X,tt0.Y,tt0.Z);
                    st.Push(tt2);
                    TrangThai tt3=new TrangThai(tt0.soDia-1,tt0.soDia-1,tt0.X,tt0.Z,tt0.Y);
                    st.Push(tt3);
                }
            }
        }
        public static void Chuyen(int n, char X, char Z)
        {
            System.Console.WriteLine("chuyen dia {0} tu cot {1} sang cot {2}\n", n, X, Z);
        }
    }
}
